{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 数学函数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **将数组a中大于30的值替换为30，小于10的值替换为10。**\n",
    "\n",
    "- `a = np.random.uniform(1, 50, 20)`\n",
    "\n",
    "【知识点：数学函数、搜索】\n",
    "- 如何将大于给定值的所有值替换为给定的截止值？"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **找到一个一维数字数组a中的所有峰值。峰顶是两边被较小数值包围的点。**\n",
    "\n",
    "- `a = np.array([1, 3, 7, 1, 2, 6, 0, 1])`\n",
    "\n",
    "【知识点：数学函数、搜索】\n",
    "- 如何在一维数组中找到所有的局部极大值（或峰值）？"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **对于给定的一维数组，计算窗口大小为3的移动平均值。**\n",
    "\n",
    "- `z = np.random.randint(10, size=10)`\n",
    "\n",
    "【知识点：数学函数】\n",
    "- 如何计算numpy数组的移动平均值？"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **对一个5x5的随机矩阵做归一化**\n",
    "\n",
    "-`Z = np.random.random((5,5))` \n",
    "\n",
    "【知识点：数学函数】\n",
    "- (提示: (x - min) / (max - min))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **用五种不同的方法去提取一个随机数组的整数部分**\n",
    "\n",
    "- `Z = np.random.uniform(0,10,10) `\n",
    "\n",
    "【知识点：数学函数】\n",
    "\n",
    "- (提示: %, np.floor, np.ceil, astype, np.trunc)"
   ]
  },
  {
   "attachments": {
    "image.png": {
     "image/png": "iVBORw0KGgoAAAANSUhEUgAAAKcAAAC9CAYAAADWW20RAAAOCElEQVR4Ae2da3LkKgyFvcZUzYZSvZXOUjoLyY8sgynwi4cEAmyjtM+tuhUbgwyHr2UMaDwZ/AcFlCowKa0XqgUFDOAEBGoVAJxquwYVA5xgQK0CgFNt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+nVZ3jxpqp53ThH83eeK0BPQ5dr4qiLwHnJlfuQCmcy6O0A6T0ET7bZD0eo5Lz4NvLz1Kv3HSUBDxJHqY+d0pWCucS9dgBp+1EB+i2/Jl5FOd63Hnh9Y1fYEMCniRPrk43uTYIzrsFuIUvVfblqtaD34THoJlD4AxqgBMowCgAOBlhkDxeAcA5vg9QA0YBwMkIg+TxCgDO8X2AGjAKAE5GGCSPVwBwju8D1IBRAHAywiB5vAKAc3wfoAaMAoCTEQbJ4xUAnOP7ADVgFACcjDBIHq8A4BzfB6gBowDgZIRB8ngFAOf4PkANGAUAJyMMkscrADjH9wFqwCgAOBlhkDxeAcA5vg9QA0YBwMkIg+TxCgDO8X2AGjAK/AfMSn4HhuLGrAAAAABJRU5ErkJggg=="
    }
   },
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **考虑一维数组Z，构建一个二维数组，其第一行为（Z [0]，Z [1]，Z [2]），随后的每一行都移位1（最后一行应为（Z [ -3]，Z [-2]，Z [-1]）**\n",
    "\n",
    "【知识点：数学函数】\n",
    "\n",
    "- （提示np.lib.stride_tricks）\n",
    "\n",
    "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]--------> ![image.png](attachment:image.png) "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **考虑两组点集P0和P1去描述一组线(二维)和一个点p,如何计算点p到每一条线 i (P0[i],P1[i])的距离？**\n",
    "- `P0 = np.random.uniform(-10,10,(10,2))\n",
    "P1 = np.random.uniform(-10,10,(10,2))\n",
    "p  = np.random.uniform(-10,10,( 1,2))`\n",
    "\n",
    "【知识点：数学函数】\n",
    "- 提示 设P(x0,y0)，直线方程为：Ax+By+C=0\n",
    "则P到直线的距离为:d=|Ax0+By0+C|/√(A²+B²)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **画正弦函数和余弦函数， x = np.arange(0, 3 * np.pi, 0.1)？**\n",
    "【知识点：数学函数】"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **减去矩阵每一行的平均值 ？**\n",
    "【知识点：数学函数】\n",
    "- 提示: mean(axis=,keepdims=)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **进行概率统计分析 ？**\n",
    "- `arr1 = np.random.randint(1,10,10)\n",
    "arr2 = np.random.randint(1,10,10))\n",
    "【知识点：数学函数】 \n",
    "平均数，中位数，方差，标准差，相关性矩阵，协方差矩阵等`\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 逻辑函数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **获取a和b元素匹配的位置。**\n",
    "- `a = np.array([1, 2, 3, 2, 3, 4, 3, 4, 5, 6])`\n",
    "- `b = np.array([7, 2, 10, 2, 7, 4, 9, 4, 9, 8])`\n",
    "\n",
    "【知识点：逻辑函数】\n",
    "- 如何得到两个数组元素匹配的位置？"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **获取5到10 之间的所有元素。**\n",
    "- `a = np.array([2, 6, 1, 9, 10, 3, 27])`\n",
    "\n",
    "【知识点：逻辑函数】\n",
    "- 如何从numpy数组中提取给定范围内的所有元素？"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **对于两个随机数组A和B,检查他们是否相等**\n",
    "- `A = np.random.randint(0,2,5)\n",
    "B = np.random.randint(0,2,5)`\n",
    "\n",
    "【知识点：逻辑函数】\n",
    "\n",
    "- (提示: np.allclose, np.array_equal)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **何对布尔值取反，或者原位(in-place)改变浮点数的符号(sign)？**\n",
    "\n",
    "【知识点：逻辑函数】\n",
    "- (提示: np.logical_not, np.negative)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **找出数组中与给定值最接近的数**\n",
    "\n",
    "【知识点：逻辑函数】\n",
    "- (提示: np.abs().argmin())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.10"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
